package gof.com.yew.singleton;

import java.io.Serializable;

public class SingletonDemo07 implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private static SingletonDemo07 instance ;
	
	private SingletonDemo07() {}
	
	public static synchronized SingletonDemo07 getInstance() {
		if(instance == null) {
			instance = new SingletonDemo07();
		}
		return instance;
	}
	
	//反序列化时直接调用该方法返回，而不需要单独再创建对象
	private Object readResolve(){
		return instance;
	}

}
